package cn.mazexal.exambg.controller;

import cn.mazexal.exambg.common.models.PagedResponse;
import cn.mazexal.exambg.common.models.SingleResponse;
import cn.mazexal.exambg.models.qry.ExamPageQry;
import cn.mazexal.exambg.models.qry.IDQry;
import cn.mazexal.exambg.models.vo.ExamPageVO;
import cn.mazexal.exambg.services.ExamService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: Mazexal
 * Date: 2025/5/13
 */
@RestController
@RequestMapping("/exam")
public class ExamController {
    @Resource
    private ExamService examService;

    @PostMapping("/getExamPageList")
    public PagedResponse<ExamPageVO> getExamPageList(@RequestBody ExamPageQry qry) {
        return PagedResponse.of(examService.getExamPageList(qry));
    }

    @PostMapping("/getExamPage")
    public SingleResponse<ExamPageVO> getExamPage(@RequestBody IDQry id) {
        return SingleResponse.of(examService.getExamPage(id.getId()));
    }

    @PostMapping("/addExamPage")
    public SingleResponse<Boolean> addExamPage(@RequestBody ExamPageVO examPageVO) {
        return SingleResponse.of(examService.addExamPage(examPageVO));
    }

    @PostMapping("/updateExamPage")
    public SingleResponse<Boolean> updateExamPage(@RequestBody ExamPageVO examPageVO) {
        return SingleResponse.of(examService.updateExamPage(examPageVO));
    }

    @PostMapping("/deleteExamPage")
    public SingleResponse<Boolean> deleteExamPage(@RequestBody IDQry id) {
        return SingleResponse.of(examService.deleteExamPage(id.getId()));
    }

}
